package com.yoda.mall.model.dto;

import com.yoda.common.constant.RC;
import com.yoda.common.utils.Utils;
import com.yoda.mall.model.entity.oms.OrderReturnApply;
import lombok.Data;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.RequestParam;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;

/**
 * @author shawn
 * @date 2022年 12月 18日 21:03
 */
@Data
public class ReturnApplyPageDto {

    private Integer  pageNum = 0;
    private Integer  pageSize = 5;
    private Long  id;
    private Integer  status;
    private String  createTime;
    private String  handleMan;
    private String  handleTime;

    public static OrderReturnApply init(ReturnApplyPageDto dto) throws ParseException {
        OrderReturnApply apply = new OrderReturnApply();
        BeanUtils.copyProperties(dto,apply);
        if (StringUtils.isNotEmpty(dto.createTime)){
            apply.setCreateTime(LocalDateTime.parse(dto.createTime));
        }

        if (StringUtils.isNotEmpty(dto.handleTime)){
            apply.setHandleTime(Utils.stringDateFormatTransfer(dto.handleTime));
        }
        return apply;
    }
}
